package com.hqyj.paimaisys.web;

import lombok.Data;

import javax.xml.ws.Response;

//定义响应结果
@Data
public class ResponseResult<T> {
    //响应码
    private Integer code;
    //响应码描述
    private String msg;
    //响应数据
    private T data;

    public ResponseResult(){
        code = 200;
        msg = "操作成功";
    }

    public static <T> ResponseResult<T> success(){
        return new ResponseResult();
    }

    public static <T> ResponseResult success(T data){
        ResponseResult result =  new ResponseResult();
        result.data = data;
        return result;
    }

    public static ResponseResult error(){
        ResponseResult result = new ResponseResult();
        result.code = 500;
        result.msg = "服务器异常";
        return result;
    }

    public static <T> ResponseResult error(T data){
        ResponseResult result = new ResponseResult();
        result.code = 500;
        result.msg = "服务器异常";
        result.data = data;
        return result;
    }
}
